﻿//Start: Scroll Bar Related
var scrollingSpeed = -3;
var scrollPopup = false;
var pos1, pos2, width;
function doScroll() {
    pos1 = pos1 + scrollingSpeed;
    pos2 = pos2 + scrollingSpeed;
    $("#scroller1").css({ "left": pos1 + "px" });
    $("#scroller2").css({ "left": pos2 + "px" });

    if (pos1 < (width * -1)) {
        pos1 = pos2 + width;
        $("#scroller1").css({ "left": pos1 + "px" });
    }
    if (pos2 < (width * -1)) {
        pos2 = pos1 + width;
        $("#scroller2").css({ "left": pos2 + "px" });
    }
    if (pos1 > width) {
        pos1 = pos2 - width;
        $("#scroller1").css({ "left": pos1 + "px" });
    }
    if (pos2 > width) {
        pos2 = pos1 - width;
        $("#scroller2").css({ "left": pos2 + "px" });
    }
}


$(document).ready(function () {
    if (document.getElementById("scrollerWrapper")) {
        var scrollerBar1 = document.getElementById("scroller1");
        var scrollerBar2 = document.getElementById("scroller2");
        scrollerBar2.innerHTML = scrollerBar1.innerHTML;
        width = parseInt($("#scroller1").css("width"));
        pos1 = $("#scroller1").position().left;
        pos2 = $("#scroller2").position().left;
        var scrollInt = setInterval("doScroll()", 60);
    }

    $("#scrollingHotSpotLeft").mouseover(function () {
        scrollingSpeed = 9;
    });

    $("#scrollingHotSpotLeft").mouseout(function () {
        scrollingSpeed = 3;
    });

    $("#scrollingHotSpotRight").mouseover(function () {
        scrollingSpeed = -9;
    });

    $("#scrollingHotSpotRight").mouseout(function () {
        scrollingSpeed = -3;
    });


    $("div#makeMeScrollable div.item").mouseover(function () {
        scrollingSpeed = 0;
    });
    $("div#makeMeScrollable div.item").mouseout(function () {
        if (!scrollPopup) {
            scrollingSpeed = -3;
        }
    });
});
//End: Scroll Bar Related